<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>下订单</title>
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/util.js"></script>
    <script>
        window.onload=function (){
            showProduct();
        }
        async function showProduct(){
            let info =await ajaxGet("/order/findByItemStatus");
            let str ="";
            for (let i = 0; i < info.length; i++) {
                let obj = info[i];
                str+=`<tr>
                <td>${obj.id}</td>
                <td>${obj.receiver}</td>
                <td>${obj.phone}</td>
                <td>${obj.orderMoney}</td>
                <td><a href="javascript:finish(${obj.id})">结账</a></td></tr>`;
            }
            $("data").innerHTML=str;
        }
        async function finish(id){
            let info =await ajaxGet("/order/finish",{id});
            if (info == "ok"){
                showProduct();
            }
        }
    </script>
</head>
<body>
    <h1>你有新订单啦</h1>
    <table border="1" cellspacing="0" width="60%">
        <thead><tr><th>订单号</th><th>收货人</th><th>收货人电话</th><th>订单总价</th><th>结账</th></tr></thead>
        <tbody id="data"></tbody>
    </table>
</body>
</html>